#include <nds.h>
#include <stdio.h>

void drawBg8x8(int *tilePos, int tile){

  *(BG_MAP_RAM(0) + *tilePos) = tile;
  *tilePos += 1;

}

void drawBg16x16(int *tilePos, int tile){

  if(*tilePos % 32 == 0 && *tilePos != 0) *tilePos += 32;
  *(BG_MAP_RAM(0) + *tilePos) = tile;
  *(BG_MAP_RAM(0) + *tilePos + 1) = tile + 1;
  *(BG_MAP_RAM(0) + *tilePos + 32) = tile + 2;
  *(BG_MAP_RAM(0) + *tilePos + 33) = tile + 3;
  *tilePos += 2;

}

void drawBg32x32(int *tilePos, int tile){

  if(*tilePos % 32 == 0 && *tilePos != 0) *tilePos += 96;
  *(BG_MAP_RAM(0) + *tilePos) = tile;
  *(BG_MAP_RAM(0) + *tilePos + 1) = tile + 1;
  *(BG_MAP_RAM(0) + *tilePos + 2) = tile + 2;
  *(BG_MAP_RAM(0) + *tilePos + 3) = tile + 3;
  *(BG_MAP_RAM(0) + *tilePos + 32) = tile + 4;
  *(BG_MAP_RAM(0) + *tilePos + 33) = tile + 5;
  *(BG_MAP_RAM(0) + *tilePos + 34) = tile + 6;
  *(BG_MAP_RAM(0) + *tilePos + 35) = tile + 7;
  *(BG_MAP_RAM(0) + *tilePos + 64) = tile + 8;
  *(BG_MAP_RAM(0) + *tilePos + 65) = tile + 9;
  *(BG_MAP_RAM(0) + *tilePos + 66) = tile + 10;
  *(BG_MAP_RAM(0) + *tilePos + 67) = tile + 11;
  *(BG_MAP_RAM(0) + *tilePos + 96) = tile + 12;
  *(BG_MAP_RAM(0) + *tilePos + 97) = tile + 13;
  *(BG_MAP_RAM(0) + *tilePos + 98) = tile + 14;
  *(BG_MAP_RAM(0) + *tilePos + 99) = tile + 15;
  *tilePos += 4;

}

void drawBg32x32Iso(u16 *bg, int *tilePos, int tile, int offSet){

  //int i;

  if(!(*tilePos % 30 == 0 && *tilePos != 0)){
    //for(i = 0; i < 16; i++)
      //*(bg + *tilePos + (i / 4) * 32 + i % 4 + 32 * offSet) = tile + i;
    *(bg + *tilePos + 0 + 32 * offSet) = tile + 0;
    *(bg + *tilePos + 1 + 32 * offSet) = tile + 1;
    *(bg + *tilePos + 2 + 32 * offSet) = tile + 2;
    *(bg + *tilePos + 3 + 32 * offSet) = tile + 3;
    *(bg + *tilePos + 32 + 32 * offSet) = tile + 4;
    *(bg + *tilePos + 33 + 32 * offSet) = tile + 5;
    *(bg + *tilePos + 34 + 32 * offSet) = tile + 6;
    *(bg + *tilePos + 35 + 32 * offSet) = tile + 7;
    *(bg + *tilePos + 64 + 32 * offSet) = tile + 8;
    *(bg + *tilePos + 65 + 32 * offSet) = tile + 9;
    *(bg + *tilePos + 66 + 32 * offSet) = tile + 10;
    *(bg + *tilePos + 67 + 32 * offSet) = tile + 11;
    *(bg + *tilePos + 96 + 32 * offSet) = tile + 12;
    *(bg + *tilePos + 97 + 32 * offSet) = tile + 13;
    *(bg + *tilePos + 98 + 32 * offSet) = tile + 14;
    *(bg + *tilePos + 99 + 32 * offSet) = tile + 15;
    *tilePos += 2;
  }

}